//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

//====================================================
// Created     : 2004-1-7
// Author      : Fan Dian
// Description : Some Test Functions for setupsegments
//====================================================

#include <core.h>
#include "registers.h"
#include "testhlp.h"
#include "interrupts.h"

//====================================================
// Description  : Print the info. about setup segments
// Parameters   : None
// Return       : None
//====================================================
inline void TestSegments()
{
    kprintf("cs(Code Segment) = 0x%lx\n", GetCs());
    kprintf("ds(Data Segment) = 0x%lx\n", GetDs());
    kprintf("es(Extra Segment) = 0x%lx\n", GetEs());
    kprintf("fs(Extra Segment) = 0x%lx\n", GetFs());
    kprintf("gs(Extra Segment) = 0x%lx\n", GetGs());
    kprintf("ss(Stack Segment) = 0x%lx\n", GetSs());
    kprintf("tss(Task State Segment) = 0x%lx\n", GetTss());
    GdtPointer gdtPointer = GetGdt();
    kprintf("gdt(Global Description Table): Limit = 0x%x\n", \
        gdtPointer.u16Limit);
    TestPrintMem((Byte *)(gdtPointer.u32Base), gdtPointer.u16Limit + 1);
    kprintf("ldt(Local Description Table) = 0x%lx\n", GetLdt());
    IdtPointer idtPointer = GetIdt();
    kprintf("idt(Interrupt Description Table): Limit = 0x%x\n", \
        idtPointer.u16Limit);
    if (idtPointer.u32Base == (uint32_t)g_idt)
        kprintf("idt register is ok\n");
    else
        kprintf("!!!ERROR!!! idt register is bad\n");
}
